<template>
<div>
  <el-table
    :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
    style="width: 100%"
    max-height="450">
    <el-table-column
      fixed
      prop="loanInfo.loanDateTime"
      label="申请时间"
      width="180">
    </el-table-column>
    <el-table-column
      prop="userInfo.uname"
      label="姓名"
      width="100">
    </el-table-column>
    <el-table-column
      prop="userInfo.uid"
      label="身份证"
      width="180">
    </el-table-column>
    <el-table-column
      prop="loanInfo.loanBalance"
      label="贷款金额"
      width="90">
    </el-table-column>
    <el-table-column
      prop="loanInfo.loanTime"
      label="贷款期限"
      width="80">
    </el-table-column>
    <el-table-column
      prop="loanInfo.loanPurpost"
      label="贷款用途"
      width="300">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="审批状态"
      width="150">
      <template slot-scope="scope">
        <el-switch
            v-model="switchStatu"
            v-bind:disabled="scope.row.loanInfo.loanDataTime!=0"
            active-color="#ff4949"
            active-text="已驳回">
        </el-switch>
      </template>
    </el-table-column>
  </el-table>
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5,10,20,50]"
        :page-size="pagesize" 
        layout="total, sizes, prev, pager, next, jumper"
        :total="tableData.length">
    </el-pagination>
</div>
</template>

<script>
import Qs from 'qs'
  export default {
    inject:['reload'],
    data() {
      return {
        switchStatu:true,//'switch设置为激活'
        small:true,//设置分页
        currentPage:1,
        pagesize:5,
        tableData:[],
      }
    },
    mounted: function(){
        this.getAllNoPassLoanInfo();
    },
    methods: {
        getAllNoPassLoanInfo : function(){//获取所有已驳回的申请
            this.$axios
            .post('/bk-user/getAllNoPassLoanInfo',
                    {headers:{'Content-Type':'application/x-www-form-urlencoded'}}
            )
            .then(result => { 
                if(result.data.code==200){
                    for(var i=0;i<result.data.data.length;i++){
                        this.tableData.push(
                            result.data.data[i]
                        );
                    }
                }
            })
            .catch(failResponse => {
                
            })
        },
        handleSizeChange: function (size) {
        this.pagesize = size;
        },
        handleCurrentChange: function(currentPage){
            this.currentPage = currentPage;
        }
    },
  }
</script>